package com.study.english.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.study.english.pojo.vo.SysRouteVo;
import com.study.english.result.Result;
import com.study.english.service.ISysRouteService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import com.study.english.domain.SysRoute;

import org.springframework.web.bind.annotation.*;

/**
 * @author wf
 * @description 针对表【sys_route】的数据库操作Controller
 * @createDate 2024-03-14 08:57:12
 */
@RestController
@RequestMapping("sysRoute")
public class SysRouteController {

    @Autowired
    private ISysRouteService sysRouteService;


    /**
     * 新增:
     */
    @PostMapping("addSysRoute")
    public Result addSysRoute(@RequestBody SysRouteVo sysRouteVo) {
        sysRouteService.addSysRoute(sysRouteVo);
        return Result.success();

    }


    /**
     * 分页查询:
     */
    @PostMapping("getSysRoutePageList")
    public Result getSysRoutePageList(@RequestBody SysRouteVo sysRouteVo) {

        IPage<SysRouteVo> page = new Page<>(sysRouteVo.getPageNum(), sysRouteVo.getPageSize());
        IPage<SysRouteVo> list = sysRouteService.getSysRoutePageList(page, sysRouteVo);
        return Result.success(list);
    }


    /**
     * 不分页查询:
     */

    @PostMapping("getSysRouteList")
    public Result getSysRouteList(@RequestBody SysRouteVo sysRouteVo) {
        List<SysRouteVo> sysRouteVoList = sysRouteService.getSysRouteList(sysRouteVo);
        return Result.success(sysRouteVoList);
    }

    @GetMapping("getSysRouteParentTreeList")
    public Result getSysRouteParentTreeList() {
        List<SysRouteVo> sysRouteVoList = sysRouteService.getSysRouteTreeList();
        return Result.success(sysRouteVoList);
    }

    /**
     * 根据id查询详情:
     */

    @GetMapping("getSysRouteById")
    public Result getSysRouteById(@RequestParam String id) {
        SysRoute sysRoute = sysRouteService.getSysRouteById(id);
        return Result.success(sysRoute);
    }

    /**
     * 根据id删除:
     */
    @GetMapping("delSysRoute")
    public Result delSysRoute(@RequestParam String id) {
        sysRouteService.delSysRoute(id);
        return Result.success();
    }


    /**
     * 修改:
     */
    @PostMapping("updateSysRoute")
    public Result updateSysRoute(@RequestBody SysRouteVo sysRouteVo) {
        sysRouteService.updateSysRoute(sysRouteVo);
        return Result.success();

    }
}
